﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sinacor.OMM.ConnectionManager.ErrorHandlers
{
    public class QueueLimitReached : IErrorHandler
    {
        #region IErrorHandleStrategy Members

        public string HandleError(PSE.Framework.Messaging.Msmq msmq, Exception exception)
        {
            PSE.Framework.Messaging.MsmqSender msmqSender = (PSE.Framework.Messaging.MsmqSender)msmq;
            StringBuilder error = new StringBuilder();

            error.AppendFormat("FILA EXCEDEU OS LIMITES DEFINIDOS {0}", Environment.NewLine);
            error.AppendFormat("Tamanho máximo definido....: [{0} bytes.{1}", msmqSender.QueuedBytesLimit, Environment.NewLine);
            error.AppendFormat("Tamanho atual..............: [{0} bytes.{1}", msmqSender.QueueSizeBytes, Environment.NewLine);
            error.AppendFormat("Tamanho máximo definido....: [{0} messages.{1}", msmqSender.QueuedMessageLimit, Environment.NewLine);
            error.AppendFormat("Tamanho atual..............: [{0} messages.{1}", msmqSender.QueuedMessages, Environment.NewLine);
            error.AppendFormat("Há uma margem de 15% entre o limite e o momento considera-se limite excedido");

            return error.ToString();
        }

        #endregion
    }
}
